/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-17
 * Time: 11:30
 */
public class Student {
    /*//就地初始化
    public String name = "李四";
    public int age = 8;*/

    public String name;
    public int age;
    public static String classes = "7";//班级 静态成员变量=》类变量   访问：类目.

    {
        name = "lisi";

        System.out.println("实例代码块！");
    }

    static{
        classes = "8";
        //类加载的时候 就被执行
        System.out.println("静态代码块！");
    }

    public Student(){
        //调用本类当中 其他的构造方法
        //this("小美", 32);//必须放在构造方法里面 并且必须是第一行
        System.out.println("不带参数的构造方法");
    }

    public Student(String name, int age){
        //this();   会报错 不能循环调用
        System.out.println("带2个参数的构造方法");
        this.name = name;
        this.age = age;
    }

    public void setStudent(String name, int age){
        this.name = name;
        this.age = age;
    }

    public void print(){
        System.out.println(this.name+" => "+this.age+"->"+classes);
    }

    public static void func2(){
        //this.print();
    }

    public static void main(String[] args) {
        Student student1 = new Student();
        System.out.println("==========");
        Student student2 = new Student();

        System.out.println(Student.classes);
    }

    {

    }

    public static void main4(String[] args) {
        Student.classes = "8";
        Student.func2();//静态的不依赖于对象

        Student student1 = new Student("张三", 18);
        student1.print();
    }

    public static void main3(String[] args) {
        Student student1 = new Student("张三", 18);
        Student student2 = new Student("李四", 28);
        Student student3 = new Student("王五", 9);

        student1.print();
        student2.print();
        student3.print();
    }

    public static void main1(String[] args) {

        Student student = new Student();

        //Student student2 = new Student("王五",18);

        //System.out.println(student.name);

        //student.setStudent("张三", 12);
        //student.print();
    }

}
